/**
 * Created by ACER on 2017/11/15.
 */

function weatherView(){
    $(".nextDay").show();
}
function weatherViewRemove(){
    $(".nextDay").hide();
}
function findWeather() {
    var oCity = "林芝";//设置城市
    $.ajax({
        type: "GET",//默认是GET
        url: "http://api.map.baidu.com/telematics/v3/weather?location=" + oCity + "&output=json&ak=ohA7QHfg0BBrpiY4kyuIAAsD",
        dataType: "jsonp",
        success: function (data) {
            $("#date").text(data.date);
            $("#currentCity").text(data.results[0].currentCity);
            $("#today_date").text(data.results[0].weather_data[0].date);
            $("#today_day").attr("src", data.results[0].weather_data[0].dayPictureUrl);
            $("#today_night").attr("src", data.results[0].weather_data[0].nightPictureUrl);
            $("#today_weather").text(data.results[0].weather_data[0].weather);
            $("#today_temperature").text(data.results[0].weather_data[0].temperature);

            $("#tomorrow_date").text(data.results[0].weather_data[1].date);
            $("#tomorrow_day").attr("src", data.results[0].weather_data[1].dayPictureUrl);
            $("#tomorrow_night").attr("src", data.results[0].weather_data[1].nightPictureUrl);
            $("#tomorrow_weather").text(data.results[0].weather_data[1].weather);
            $("#tomorrow_temperature").text(data.results[0].weather_data[1].temperature);

            $("#tomorrowAfter_date").text(data.results[0].weather_data[2].date);
            $("#tomorrowAfter_day").attr("src", data.results[0].weather_data[2].dayPictureUrl);
            $("#tomorrowAfter_night").attr("src", data.results[0].weather_data[2].nightPictureUrl);
            $("#tomorrowAfter_weather").text(data.results[0].weather_data[2].weather);
            $("#tomorrowAfter_temperature").text(data.results[0].weather_data[2].temperature);
        },
        error: function (jqXHR) {
            alert("抱歉，天气暂无数据")
        }
    });
}
findWeather();
$(document).ready(function() {
    $(".nextDay").hide();

    $("#menu2 li a").wrapInner( '<span class="out"></span>' );

    $("#menu2 li a").each(function() {
        $( '<span class="over">' +  $(this).text() + '</span>' ).appendTo( this );
    });

    $("#menu2 li a").hover(function() {
        $(".out",	this).stop().animate({'top':	'68px'},	300); // move down - hide
        $(".over",	this).stop().animate({'top':	'0px'},		300); // move down - show

    }, function() {
        $(".out",	this).stop().animate({'top':	'0px'},		300); // move up - show
        $(".over",	this).stop().animate({'top':	'-68px'},	300); // move up - hide
    });

});
